<template>

  <el-scrollbar height="400px">
    <el-row>
      <el-col :span="4">
        <div class="grid-content bg-purple">
          总计
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content bg-purple-light">
          {{ data.length }}
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content bg-purple">
          {{ totalPoint }}
        </div>
      </el-col>
      <el-col :span="12">
        <div class="grid-content bg-purple-light">

        </div>
      </el-col>

    </el-row>
    <el-row>
      <el-col :span="4">
        <div class="grid-content bg-purple">
          序号
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content bg-purple-light">
          任务ID
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content bg-purple">
          点数
        </div>
      </el-col>
      <el-col :span="12">
        <div class="grid-content bg-purple-light">
          状态
        </div>
      </el-col>

    </el-row>


    <el-row v-for="(value,index) in data " :key="index">
      <el-col :span="4">
        <div class="grid-content bg-purple">
          {{ index + 1 }}
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content  bg-purple-light">
          {{ value.id }}
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content bg-purple">
          {{ value.awardPoint }}
        </div>
      </el-col>
      <el-col :span="12">
        <div class="grid-content  bg-purple-light">
          {{ value.type }}
        </div>
      </el-col>
    </el-row>


  </el-scrollbar>
</template>

<script setup lang="ts">

import getDoneDetailedTaskByCrowdId from "@/api/task/getList/getDoneDetailedTaskByCrowdId";
import getDoneRoughTaskByCrowdId from "@/api/task/getList/getDoneRoughTaskByCrowdId";
import {ref} from "vue";
import getAwardPoint from "@/api/awardPoint/getAwardPoint";

const userId = sessionStorage.getItem("user.id");
const data = ref<[]>([]);
getDoneDetailedTaskByCrowdId(parseInt(userId))
    .then((response) => {
      for (let i = 0; i < response.data.length; i++) {
        data.value.push({
          ...response.data[i],
          type: 'detailed'
        })
      }
    });

getDoneRoughTaskByCrowdId(parseInt(userId))
    .then((response) => {
      for (let i = 0; i < response.data.length; i++) {
        data.value.push({
          ...response.data[i],
          type: 'rough'
        })
      }
    })

const totalPoint = ref();

getAwardPoint(parseInt(userId))
    .then((response) => {
      totalPoint.value = response.data;
    })


</script>

<style scoped>

.el-row {
  margin-bottom: 20px;
}

.el-row:last-child {
  margin-bottom: 0;
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: #99a9bf;
}

.bg-purple {
  background: #d3dce6;
}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

.scrollbar-demo-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  margin: 10px;
  text-align: center;
  border-radius: 4px;
  background: var(--el-color-primary-light-9);
  color: var(--el-color-primary);
}
</style>